import Vue from 'vue'
Vue.config.productionTip = false
// 配置全局token
axios.defaults.headers.common['Authorization'] = window.localStorage.getItem('token');
import App from './App.vue'
//引入路由
import Router from 'vue-router'
//使用路由
Vue.use(Router)
//引入路由配置文件
import router from './router'
//引入插件
import thirduse from './myuse/thirduse.js'
// 使用插件
Vue.use(thirduse)
//引入axios
import axios from 'axios'
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/';
// 添加请求拦截器
axios.interceptors.request.use(function (config) {
  // 在发送请求之前做些什么
  config.headers.Authorization = window.localStorage.getItem('token')
  return config;
}, function (error) {
  // 对请求错误做些什么
  return Promise.reject(error);
});

Vue.prototype.axios = axios
//引入全局消息提示框
import { Message } from 'element-ui';
Vue.prototype.$message = Message;
Vue.prototype.$confirm = Message
//引入全局提交内容框
import { MessageBox } from 'element-ui';
Vue.prototype.MessageBox = MessageBox
//引入dayjs
import dayjs from 'dayjs'
//全局过滤器
Vue.filter('timeFormat', function (timeVal) {
  let times = dayjs.unix(timeVal);
  return dayjs(times).format("YYYY-MM-DD HH:mm:ss");
})
Vue.filter('price', function (priceVal) {
  return priceVal.toFixed(2)
})
Vue.filter('weight', function (weightVal) {
  return weightVal = weightVal + 'g'
})
//注册全局富文本
import VueQuillEditor from 'vue-quill-editor'
// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)
new Vue({
  router,
  render: h => h(App),
}).$mount('#app')
